//
//  ChinaPetroleumMachineryViewController.m
//  AnXin100
//
//  Created by Sakura on 2018/11/12.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "ChinaPetroleumMachineryViewController.h"
#import "ChinaPetroleumMachineryTableViewCell.h"
@interface ChinaPetroleumMachineryViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *mainTable;

@end

@implementation ChinaPetroleumMachineryViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.mainTable];
    
    NSArray *array = @[@"农机前沿", @"有机农"];
    for (NSInteger i = 0; i < 2; i++) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(SCREEN_WIDTH / 2 * i, Hn, SCREEN_WIDTH / 2, 30);
        button.titleLabel.font = [UIFont systemFontOfSize:14];
        [button setTitleColor:COLOR_Gray forState:UIControlStateNormal];
        [button setTitleColor:COLOR_GREEN forState:UIControlStateSelected];
        [button setTitle:array[i] forState:UIControlStateNormal];
        [self.view addSubview:button];
        if (i == 0) {
            button.selected = YES;
        }
    }
}


#pragma lazy load
- (UITableView *)mainTable {
    if (!_mainTable) {
        _mainTable = [[UITableView alloc] initWithFrame:CGRectMake(0, Hn + 30, SCREEN_WIDTH, SCREEN_HEIGHT - Hn - 30) style:UITableViewStylePlain];
        _mainTable.delegate = self;
        _mainTable.dataSource = self;
        _mainTable.separatorStyle = UITableViewCellSeparatorStyleNone;
        [_mainTable registerClass:[ChinaPetroleumMachineryTableViewCell class] forCellReuseIdentifier:@"ChinaPetroleumMachineryTableViewCell"];
    }
    return _mainTable;
}

#pragma mark - UITableView Delegate

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 130;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    ChinaPetroleumMachineryTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ChinaPetroleumMachineryTableViewCell"];
    return cell;
    
}
@end
